unit datamodule;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, ZConnection, ZDataset, fpjson, jsonparser,  contnrs, base64;

type

  //URL记录
  TnkUrlItem = record
    pkey:string[255];
    proot:string[255];
    purl:string[255];
  end;
  PnkUrlItem = ^TnkUrlItem;

  //自定义页面按钮
  TnkPage = record
    id:integer;
    caption:string[255];
    url:string[255];
    Flag:integer;
  end;

  //脚本记录
  TnkScript = record
    Mode:string;
    Kind:string;
    Caption:string;
    Url:string;
    Script:string;
  end;

  //定点机构实时监控对象
  TnkHisWatcher  = record
    tag:integer;
    caption:string;
    user:string;
    pwd:String;
    page:integer;
  end;

  //URL管理对象

  { TnkUrls }

  TnkUrls = class(TComponent)
  private
    FList:TList;
    function GetCount: integer;
  public
    constructor Create(AOwner:TComponent);override;
    destructor Destroy; Override;
    procedure Clear;//清除所有项目
    procedure Add(AKey, ARoot, AUrl:string);//增加新项目
    function IndexOf(AKey:string):integer;//根据Key查找记录
    function Item(AIndex:integer):TnkUrlItem;//根据下标返回记录
  published
    property Count:integer read GetCount;
  end;

  //分析报告对象

  { TnkReport }

  TnkReport = class(TComponent)
  private
    FCMonth: integer;
    FCyear: integer;
    FTipsCount: integer;
    FTitle: string;
    FWarningCount: integer;
    FWarningJson:TJsonObject;
    FTipsJson:TJsonObject;
    FDetailJson:TJsonObject;
    function GetDetail: string;
    function GetTips: string;
    function GetWarning: string;
  public
    constructor Create(AOwner:TComponent);override;
    destructor  Destroy;override;
    procedure AddWarning(AKey,AValue:string);
    procedure AddTips(AKey, AValue:string);
    procedure AddDetail(AKey, AValue:string);
    procedure AddDetail(AKey:string;AJson:TJsonObject);overload;
    function WarningKey(AIndex:integer):string;
    function WarningValue(AIndex:integer):string;
    function TipsKey(AIndex:integer):string;
    function TipsValue(AIndex:integer):string;
    function WarningLength:integer;
    function TipsLength:integer;
  published
    property CYear:integer read FCyear write FCyear;
    property CMonth:integer read FCMonth write FCMonth;
    property TipsCount:integer read FTipsCount write FTipsCount;  //提示数量
    property WarningCount:integer read FWarningCount write FWarningCount; //风险点数量
    property Title:string read FTitle write FTitle;//报告标题
    property Warning:string read GetWarning;
    property Tips:string read GetTips;
    property Detail:string read GetDetail;
  end;

  //慢性病编码及医院编码对照对象

  { TnkManbingBianmaItem }

  TnkManbingBianmaItem = class(TComponent)
  private
    FCode: string;
    FLevel: string;
    FList:TStrings;
    function GetHospital: TStrings;
    procedure SetHospital(AValue: TStrings);
  public
    constructor Create(AOwner:TComponent);override;
    destructor  Destroy;override;
  published
    property Code:string read FCode write FCode;//疾病编码
    property Level:string read FLevel write FLevel;//级别编码
    property Hospital:TStrings read GetHospital write SetHospital;//对应的医院编码列表
  end;

  TnkManbingBianma = class(TComponent)
  private
    FList:TObjectList;
    function GetCount: integer;
  public
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
    procedure Clear;//清除全部
    function Add(AItem:TnkManbingBianmaItem):integer;//添加编码
    function Item(AIndex:integer):TnkManbingBianmaItem;
    function Check(ACode,AHospital:string):integer;//对比疾病编码和医院编码，返回错误码
    property Count:integer read GetCount;
  end;

  { Tdm }

  Tdm = class(TDataModule)
    conn: TZConnection;
    innerqryWork: TZQuery;
    pubqry: TZQuery;
    innerqry: TZQuery;
    connWork: TZConnection;
    pubqryWork: TZQuery;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private

  public
    Platform:string;
    Urls:TnkUrls;
    Pages:array of TnkPage;//自定义屏页面
    Scripts:array of TnkScript;//自定义脚本
    HisWatcher:array of TnkHisWatcher;//定点医药机构实时监控
    HisWatcherTag:integer;//用于注入时的状态机变量
    JuWatchUser, JuWatchPwd:string;//医保局实时监控用户名和密码

    isAdmin:integer;//是否管理员

    procedure FillPages;//填充自定义监控大屏页面
    procedure FillScripts;//填充自定义脚本
    procedure FillManbingBianma(AManbingTable,AHospitalTable:string;AObject:TnkManbingBianma;AWS:boolean=True);//填充慢病编码对象
    procedure LoadUrls;//载入URLS表
    procedure DeleteHuabo(AYear,AMonth:integer;AWS:boolean=True);//删除指定年月的划拨数据
    procedure InsertHuabo(AYear,AMonth:integer;A0,A1,A2,A3,A4,A5,A6:string;A7:double;A8,A9,A10,A11,A12,A13,A14:string;AChecked:boolean=False;AWS:boolean=True);//保存划拨数据
    procedure DeleteSiwang(AYear, AMonth:integer;AWS:boolean=True);//删除指定年月的死亡数据
    procedure InsertSiwang(AYear, AMonth:integer; A0:TDate; A1, A2, A3:string;AWS:boolean=True);//保存死亡数据
    function  GetSiwangDate(AID:string;var ADate:TDate;AWS:boolean=True):boolean;//获取指定身份证号的死亡日期
    procedure SaveHuaboFx(AR:TnkReport;ADelete:boolean;AShortKind:string='');//保存个人账户划拨风险分析报告

    {保存风险点主子表}
    function GenerateID:string;//生成唯一标识号
    procedure SaveFx(AR:TnkReport;ADelete:boolean;AShortKind:string='';AWS:boolean=True);//调用参数同SaveHuaboFx，但存储表为FxMaster和FxDetail

    procedure SaveImportLog(AKind:string;AYear,AMonth:integer;ASource,ADispFile:string;ACount:integer;AWS:boolean=True);//保存导入日志
    procedure UpdateRecordCount(AIncCount:integer);//在Stat表中增加recordCount数量
    procedure SaveAnalLog(AKind:string;AYear,AMonth,AWarningCount,ATipsCount:integer;AWS:boolean=True);//保存风险分析日志
    procedure InsertDanwei(cyear, cmonth:integer;c0,c1,c2,c3,c4,c5,c6,c7,c8,c9:string;c10,c11:TDate;c12:double;c13,c14,c15,c16,c17:integer;c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33,c34,c35,c36,c37,c38,c39,c40,c41:string;Check:boolean;AWS:boolean=True);//保存单位信息表
    procedure DeleteDanwei(AYear, AMonth:integer;AWS:boolean=True);//删除单位信息记录
    procedure DeleteZhuxiao(AYear, AMonth:integer;AWS:boolean=True);//删除企业注销名单
    procedure InsertZhuxiao(cyear, cmonth:integer; c0,c1,c2,c3,c4,c5,c6,c7:string;c8:TDate;c9,c10:string;c11:TDate;check:boolean;AWS:boolean=True);//保存企业注销名单
    procedure InsertXuesheng(cyear, cmonth:integer; c0,c1,c2:string;c3:TDate;c4,c5,c6,c7,c8:string;c9:TDate;c10,c11:string;c12:integer;c13,c14,c15:double;check:boolean;AWS:boolean=True);//保存学生参保名单
    procedure DeleteXueSheng(AYear, AMonth:integer;AWS:boolean=True);//删除学生登记表
    procedure InsertBujiao(cyear,cmonth:integer;c0,c1,c2,c3,c4,c5,c6,c7,c8:string;c9:TDate;c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28:double;c29,c30,c31:string;check:boolean;AWS:boolean=True);//保存职工医疗保险补缴表
    procedure InsertZhuanchu(cyear,cmonth:integer;c0,c1,c2,c3,c4,c5,c6,c7:string;c8:double;c9,c10,c11,c12:String;c13:TDate;c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27:string;check:boolean; AWS:boolean=True);//保存职工医疗保险转出名单表
    procedure InsertJumin(cyear,cMonth:integer;c0,c1,c2:string;c3:TDate;c4,c5,c6,c7,c8:string;c9:TDate;c10,c11:string;c12:integer;c13,c14,c15:double;check:boolean; AWS:boolean=True);//保存居民医疗保险参保人员名单表
    procedure InsertGaoxueya(cyear,cmonth:integer;c0,c1,c2,c3,c4,c5,c6:string;c7,c8:TDate;check:boolean; AWS:boolean=True);//保存高血压、糖尿病办理登记表
    procedure InsertManxingbing(cyear,cmonth:integer;c0,c1,c2,c3,c4,c5,c6,c7,c8,c9:string;c10,c11:TDate;c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22:string;check:boolean; AWS:boolean=True);//居民慢性病办理名单表存
    procedure InsertZhigongManxingbing(cyear,cmonth:integer;c0,c1,c2,c3,c4,c5,c6,c7,c8,c9:string;c10,c11:TDate;c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24:string;check:boolean; AWS:boolean=True);//职工慢性病办理名单表存
    procedure InsertManbingBianma(cyear,cmonth:integer;c0,c1,c2,c3:string;check:boolean; AWS:boolean=True);//保存居民慢性名称和编码
    procedure InsertZhigongManbingBianma(cyear,cmonth:integer;c0,c1,c2:string;check:boolean; AWS:boolean=True);//保存职工慢性名称和编码
    procedure InsertYiyuanBianma(cyear,cmonth:integer;c0,c1,c2,c3:string;check:boolean; AWS:boolean=True);//保存定点医疗机构名称编码级别对应表
    procedure InsertZhigong(cyear,cMonth:integer;c0,c1,c2,c3,c4:string;c5:TDate;c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17:string;check:boolean;AWS:boolean=True);//保存参保职工名单

    procedure DeleteZhigong(AYear, AMonth:integer;AWS:boolean=True);//删除参保职工名单
    procedure DeleteYiyuanBianma(AYear, AMonth:integer;AWS:boolean=True);//删除定点医疗机构名称编码级别对应表
    procedure DeleteManbingBianma(AYear, AMonth:integer;AWS:boolean=True);//删除居民慢性病名称和编码
    procedure DeleteZhigongManbingBianma(AYear, AMonth:integer;AWS:boolean=True);//删除职工慢性病名称和编码
    procedure DeleteBujiao(AYear, AMonth:integer;AWS:boolean=True);//删除职工医疗保险补缴表
    procedure DeleteZhuanchu(AYear, AMonth:integer;AWS:boolean=True);//删除职工医疗保险转出名单表
    procedure DeleteJumin(AYear,AMonth:integer;AWS:boolean=True);//删除居民医疗保险参保人员名单表
    procedure DeleteGaoxueya(AYear, AMonth:integer;AWS:boolean=True);//删除高血压、糖尿病办理登记表
    procedure DeleteManxingbing(AYear, AMonth:integer;AWS:boolean=True);//删除居民慢性病办理名单表
    procedure DeleteZhigongManxingbing(AYear, AMonth:integer;AWS:boolean=True);//删除职工慢性病办理名单表
    procedure ResetTable(ATable:string;AWS:boolean=True);//复位数据，删除表内全部数据
    procedure ResetBigData;//复位Stat Stat_detail表
    procedure UpdateAnalCount;//更新Stat表中analcount数量
    function RemovePercent(AText:string):string;//去除百分号
    function CheckIDCardNumber(IdCode : AnsiString): boolean; //获取身份证校验码
  end;

var
  dm: Tdm;

implementation

{$R *.frm}

{ TnkManbingBianma }

function TnkManbingBianma.GetCount: integer;
begin
  Result:=FList.Count;
end;

constructor TnkManbingBianma.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FList:=TObjectList.Create(True);
end;

destructor TnkManbingBianma.Destroy;
begin
  Clear;
  FList.Free;
  inherited Destroy;
end;

procedure TnkManbingBianma.Clear;
var
  i:integer;
begin
  if FList.Count=0 then Exit;
  for i:=FList.Count-1 downto 0 do
  begin
    FList.Delete(i);
  end;
  FList.Clear;
end;

function TnkManbingBianma.Add(AItem:TnkManbingBianmaItem):integer;
begin
  Result:=FList.Add(AItem);
end;

function TnkManbingBianma.Item(AIndex: integer): TnkManbingBianmaItem;
begin
  Result:=(FList.Items[Aindex] as TnkManbingBianmaItem);
end;

function TnkManbingBianma.Check(ACode, AHospital: string): integer;
var
  i,j:integer;
  mm:boolean;
  mCodeIndex:integer;
  mItem:TnkManbingBianmaItem;
begin
  //对比疾病编码和医院编码，返回错误码，0表示无错
  mcodeIndex:=-1;
  for i:=0 to Self.Count-1 do
  begin
    if Pos(Self.Item(i).Code,ACode)>0 then //疾病双编码
    begin
      mCodeIndex:=i;
      Break;
    end;
  end;
  if mCodeIndex=-1 then
  begin
    Result:=1;//没有找到疾病编码
    Exit;
  end
  else
  begin
    mItem:=Self.Item(mCodeIndex);
//    if mItem.Hospital.IndexOf(Ahospital)=-1 then
    mm:=False;
    for j:=0 to mItem.Hospital.Count-1 do
    begin
      if Pos(mItem.Hospital.Strings[j], AHospital)>0 then
      begin
        mm:=True;
        Break;
      end;
    end;
    //if mItem.Hospital.IndexOf(Ahospital)=-1 then
    if mm=False then
    begin
      Result:=2;//没有找到医院编码
      Exit;
    end
    else
    begin
      Result:=0;
    end;
  end;
end;

{ TnkManbingBianmaItem }

function TnkManbingBianmaItem.GetHospital: TStrings;
begin
  Result:=FList;
end;

procedure TnkManbingBianmaItem.SetHospital(AValue: TStrings);
begin
  FList.Assign(AValue);
end;

constructor TnkManbingBianmaItem.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FList:=TStringList.Create;
end;

destructor TnkManbingBianmaItem.Destroy;
begin
  FList.Free;
  inherited Destroy;
end;

{ TnkReport }

function Tdm.CheckIDCardNumber(IdCode : AnsiString): boolean;
const
  WI: array[0..16] of Integer = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
  VC: array[0..10] of AnsiChar = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
var
  P: PAnsiChar;
  I, S: Integer;
begin
  Result := False;
  if Length(IdCode) <> 18 then Exit;
  P := PAnsiChar(IdCode);
  S := 0;
  for I := 0 to 16 do
    S := S + (Ord(P[I]) - $30) * WI[I];

  S := S mod 11;
  Result := P[17] = VC[S];
end;

function TnkReport.GetTips: string;
begin
  Result:=FTipsJson.AsJSON;
end;

function TnkReport.GetDetail: string;
begin
  Result:=FDetailJson.AsJSON;
end;

function TnkReport.GetWarning: string;
begin
  Result:=FWarningJson.AsJSON;
end;

constructor TnkReport.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FWarningJson:=TJsonObject.Create;
  FTipsJson:=TJsonObject.Create;
  FDetailJson:=TJsonObject.Create;
end;

destructor TnkReport.Destroy;
begin
  FWarningJson.Free;
  FTipsJson.Free;
  FDetailJson.Free;
  inherited Destroy;
end;

procedure TnkReport.AddWarning(AKey, AValue: string);
begin
  FWarningJson.Add(AKey,AValue);
end;

procedure TnkReport.AddTips(AKey, AValue: string);
begin
  FTipsJson.Add(AKey, AValue);
end;

procedure TnkReport.AddDetail(AKey, AValue: string);
begin
  FDetailJson.Add(AKey, AValue);
end;

procedure TnkReport.AddDetail(AKey: string; AJson: TJsonObject);
begin
  FDetailJson.Add(AKey, AJson);
end;

function TnkReport.WarningKey(AIndex: integer): string;
begin
  Result:=FWarningJson.Names[AIndex];
end;

function TnkReport.WarningValue(AIndex: integer): string;
begin
  Result:=FWarningJson.Items[AIndex].AsString;
end;

function TnkReport.TipsKey(AIndex: integer): string;
begin
  Result:=FTipsJson.Names[AIndex];
end;

function TnkReport.TipsValue(AIndex: integer): string;
begin
  Result:=FTipsJson.Items[AIndex].AsString;
end;

function TnkReport.WarningLength: integer;
begin
  Result:=FWarningJson.Count;
end;

function TnkReport.TipsLength: integer;
begin
  Result:=FTipsJson.Count;
end;


{ TnkUrls }

function TnkUrls.GetCount: integer;
begin
  Result:=FList.Count;
end;

constructor TnkUrls.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FList:=TList.Create;
end;

destructor TnkUrls.Destroy;
begin
  Clear;
  FList.Free;
  inherited Destroy;
end;

procedure TnkUrls.Clear;
var
  i:integer;
begin
  for i :=0 to FList.Count-1 do
  begin
    Dispose(PnkUrlItem(FList.Items[i]));
  end;
  FList.Clear;
end;

procedure TnkUrls.Add(AKey, ARoot, AUrl:string);
var
  m:PnkUrlItem;
begin
  new(m);
  m^.pkey:=AKey;
  m^.proot:=ARoot;
  m^.purl:=AUrl;
  FList.Add(m);
end;

function TnkUrls.IndexOf(AKey: string): integer;
var
  i:integer;
begin
  Result:=-1;
  for i:=0 to FList.Count-1 do
  begin
    if PnkUrlItem(FList.Items[i])^.pkey=AKey then
    begin
      Result:=i;
      Break;
    end;
  end;
end;

function TnkUrls.Item(AIndex: integer): TnkUrlItem;
var
  m:PnkUrlItem;
begin
  if (AIndex>=0) and  (AIndex<FList.Count) then
  begin
    Result.pkey:=PnkUrlItem(FList.Items[AIndex])^.pkey;
    Result.proot:=PnkUrlItem(FList.Items[AIndex])^.proot;
    Result.purl:=PnkUrlItem(FList.Items[AIndex])^.purl;
  end;
end;

{ Tdm }

procedure Tdm.DataModuleCreate(Sender: TObject);
begin
  Urls:=TnkUrls.Create(Self);
end;

procedure Tdm.DataModuleDestroy(Sender: TObject);
begin
  Urls.Free;
end;

procedure Tdm.FillPages;
var
  i:integer;
begin
  with pubqry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from pages order by id');
    Open;
    SetLength(Pages,RecordCount);
    i:=0;
    First;
    while not Eof do
    begin
      Pages[i].caption:=FieldByName('caption').AsString;
      Pages[i].url:=FieldByName('url').AsString;
      Pages[i].id:=FieldByName('id').AsInteger;
      i:=i+1;
      Next;
    end;
  end;
end;

procedure Tdm.FillScripts;
var
  i:integer;
begin
  with pubQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from scripts order by id');
    Open;
    SetLength(Scripts, RecordCount);
    i:=0;
    while not Eof do
    begin
      Scripts[i].Kind:=FieldByName('kind').AsString;
      Scripts[i].Caption:=FieldByName('caption').AsString;
      Scripts[i].Url:=FieldByName('url').AsString;
      Scripts[i].Script:=DecodeStringBase64(FieldByName('script').AsString);
      i:=i+1;
      Next;
    end;
  end;
end;

procedure Tdm.FillManbingBianma(AManbingTable, AHospitalTable: string;
  AObject: TnkManbingBianma; AWS: boolean);
var
  mQuery:TZQuery;
  mItem:TnkManbingBianmaItem;
  procedure FillHospital(ALevel:string;AHosCode:string);
  var
    j:integer;
    mItem2:TnkManbingBianmaItem;
  begin
    for j:=0 to AObject.Count-1 do
    begin
      mItem2:=AObject.Item(j);
      if (Trim(mItem.Level)='') or (Pos('一级及以上', mItem.Level)>0) then
      begin
        //一级及以上
        if (ALevel='1') or (ALevel='2') or (ALevel='3') then
          mItem2.Hospital.Add(AHosCode);
      end
      else
      if Pos('二级及以下', mItem.Level)>0 then
      begin
        //二级及以下
        if (ALevel='1') or (ALevel='2') then
          mItem2.Hospital.Add(AHosCode);
      end;
    end;
  end;

begin
  if AWS=False then
    mQuery:=InnerQry
  else
    mQuery:=InnerQryWork;
  AObject.Clear;
  //先填充疾病编码
  with mQuery do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from '+AManBingTable);
    Open;
    First;
    while not Eof do
    begin
      mItem:=TnkManbingBianmaItem.Create(nil);
      mItem.Code:=Trim(FieldByName('c1').AsString);
      mItem.Level:=Trim(FieldByName('c3').AsString);
      AObject.Add(mItem);
      //特殊处理病种
      if Pos(mItem.Code,'N0010,N0021,N0030,N0032')>0 then
      begin
        mItem.Hospital.Add('070021');//潍坊市第二人民医院编码，待修改
      end;
      Next;
    end;
  end;
  //填充医院对应的编码
  with mQuery do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from '+AHospitalTable);
    Open;
    First;
    while not Eof do
    begin
      FillHospital(Trim(FieldByName('c3').AsString),Trim(FieldByName('c1').AsString));
      Next;
    end;
  end;
end;

procedure Tdm.LoadUrls;
begin
  Urls.Clear;
  with pubQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from urls');
    Open;
    First;
    while not Eof do
    begin
      Urls.Add(FieldByName('pkey').AsString,FieldByName('proot').AsString,FieldByName('purl').AsString);
      Next;
    end;
  end;
end;

procedure Tdm.DeleteHuabo(AYear, AMonth: integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from huabo where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from huabo where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;



procedure Tdm.InsertHuabo(AYear, AMonth: integer; A0, A1, A2, A3, A4, A5,
  A6: string; A7: double; A8, A9, A10, A11, A12, A13, A14: string;AChecked:boolean=False;AWS:boolean=True);
var
  mFlag:boolean;
begin
  mFlag:=False;
  if AChecked then
  begin
    //检查是否存在相同年月、相同社保号码、医疗账户号、卡号和银行账号的划拨记录，如果存在则跳过，否则插入
    {if AWS=False then
    begin
      with pubqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from huabo where cyear=:cyear and cmonth=:cmonth and c0=:c0 and c4=:c4 and c5=:c5 and c6=:c6');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsString:=A0;
        Params.ParamByName('c4').AsString:=A4;
        Params.ParamByName('c5').AsString:=A5;
        Params.ParamByName('c6').AsString:=A6;
        Open;
        First;
        if FieldByName('aa').AsInteger>0 then
          mFlag:=True;
      end;
    end
    else
    begin
      with pubqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from huabo where cyear=:cyear and cmonth=:cmonth and c0=:c0 and c4=:c4 and c5=:c5 and c6=:c6');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsString:=A0;
        Params.ParamByName('c4').AsString:=A4;
        Params.ParamByName('c5').AsString:=A5;
        Params.ParamByName('c6').AsString:=A6;
        Open;
        First;
        if FieldByName('aa').AsInteger>0 then
          mFlag:=True;
      end;
    end; }
  end;
  //if mFlag=False then
  if 1=1 then
  begin
    if AWS=False then
    begin
      with pubqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into huabo (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14)');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsString:=A0;
        Params.ParamByName('c1').AsString:=A1;
        Params.ParamByName('c2').AsString:=A2;
        Params.ParamByName('c3').AsString:=A3;
        Params.ParamByName('c4').AsString:=A4;
        Params.ParamByName('c5').AsString:=A5;
        Params.ParamByName('c6').AsString:=A6;
        Params.ParamByName('c7').AsFloat:=A7;
        Params.ParamByName('c8').AsString:=A8;
        Params.ParamByName('c9').AsString:=A9;
        Params.ParamByName('c10').AsString:=A10;
        Params.ParamByName('c11').AsString:=A11;
        Params.ParamByName('c12').AsString:=A12;
        Params.ParamByName('c13').AsString:=A13;
        Params.ParamByName('c14').AsString:=A14;
        ExecSQL;
      end;
    end
    else
    begin
      with pubqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into huabo (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14)');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsString:=A0;
        Params.ParamByName('c1').AsString:=A1;
        Params.ParamByName('c2').AsString:=A2;
        Params.ParamByName('c3').AsString:=A3;
        Params.ParamByName('c4').AsString:=A4;
        Params.ParamByName('c5').AsString:=A5;
        Params.ParamByName('c6').AsString:=A6;
        Params.ParamByName('c7').AsFloat:=A7;
        Params.ParamByName('c8').AsString:=A8;
        Params.ParamByName('c9').AsString:=A9;
        Params.ParamByName('c10').AsString:=A10;
        Params.ParamByName('c11').AsString:=A11;
        Params.ParamByName('c12').AsString:=A12;
        Params.ParamByName('c13').AsString:=A13;
        Params.ParamByName('c14').AsString:=A14;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.DeleteSiwang(AYear, AMonth: integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from siwang where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from siwang where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.InsertSiwang(AYear, AMonth: integer; A0: TDate; A1, A2,
  A3: string; AWS:boolean=True);
var
  mFlag:boolean;
begin
  mFlag:=False;
  if True then
  begin
    //检查是否存在火化日期、相同证件号码的记录，如果存在则跳过，否则插入
    if AWS=False then
    begin
      with pubqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from Siwang where c0=:c0 and c2=:c2');
        Params.ParamByName('c0').AsDate:=A0;
        Params.ParamByName('c2').AsString:=A2;
        Open;
        First;
        if FieldByName('aa').AsInteger>0 then
          mFlag:=True;
      end;
    end
    else
    begin
      with pubqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from Siwang where c0=:c0 and c2=:c2');
        Params.ParamByName('c0').AsDate:=A0;
        Params.ParamByName('c2').AsString:=A2;
        Open;
        First;
        if FieldByName('aa').AsInteger>0 then
          mFlag:=True;
      end;
    end;
  end;
  if mFlag=False then
  begin
    if AWS=False then
    begin
      with pubqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into siwang (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsDate:=A0;
        Params.ParamByName('c1').AsString:=A1;
        Params.ParamByName('c2').AsString:=A2;
        Params.ParamByName('c3').AsString:=A3;
        ExecSQL;
      end;
    end
    else
    begin
      with pubqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into siwang (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=AYear;
        Params.ParamByName('cmonth').AsInteger:=AMonth;
        Params.ParamByName('c0').AsDate:=A0;
        Params.ParamByName('c1').AsString:=A1;
        Params.ParamByName('c2').AsString:=A2;
        Params.ParamByName('c3').AsString:=A3;
        ExecSQL;
      end;
    end;
  end;
end;

function Tdm.GetSiwangDate(AID: string; var ADate: TDate;AWS:boolean=True): boolean;
begin
  Result:=False;
  if AWS=False then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('select * from siwang where c2=:c2');
      Params.ParamByName('c2').AsString:=AID;
      Open;
      if RecordCount>0 then
      begin
        ADate:=FieldByName('c0').AsDateTime;
        Result:=True;
      end;
    end;
  end
  else
  begin
    with InnerQryWork do
    begin
      Close;
      Sql.Clear;
      Sql.Add('select * from siwang where c2=:c2');
      Params.ParamByName('c2').AsString:=AID;
      Open;
      if RecordCount>0 then
      begin
        ADate:=FieldByName('c0').AsDateTime;
        Result:=True;
      end;
    end;
  end;
end;

procedure Tdm.SaveHuaboFx(AR: TnkReport; ADelete: boolean; AShortKind:string='');
begin
  if ADelete=True then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('delete from huabofx where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AR.CYear;
      Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
      ExecSQL;
    end;
  end;
  with InnerQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('insert into huabofx (cyear, cmonth, cwarningcount, cwarning, ctipscount, ctips, cdetail, shortkind) values (:cyear, :cmonth, :cwarningcount, :cwarning, :ctipscount, :ctips, :cdetail, :shortkind)');
    Params.ParamByName('cyear').AsInteger:=AR.CYear;
    Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
    Params.ParamByName('cwarningcount').AsInteger:=AR.WarningCount;
    Params.ParamByName('cwarning').AsString:=AR.Warning;
    Params.ParamByName('ctipscount').AsInteger:=AR.TipsCount;
    Params.ParamByName('ctips').AsString:=AR.Tips;
    Params.ParamByName('cdetail').AsString:=AR.Detail;
    Params.ParamByName('shortkind').AsString:=AShortKind;
    ExecSQL;
  end;
end;

function Tdm.GenerateID: string;
var
  m:TGUID;
  m2:string;
begin
  CreateGUID(m);
  m2:=StringReplace(GUIDToString(m),'{','',[rfReplaceall]);
  m2:=StringReplace(m2,'}','',[rfReplaceAll]);
  m2:=StringReplace(m2,'-','',[rfReplaceAll]);
  Result:=m2;
end;

procedure Tdm.SaveFx(AR: TnkReport; ADelete: boolean; AShortKind: string;AWS:boolean=True);
var
  mmainid:string;
  i:integer;
begin
  if ADelete=True then
  begin
    //清除数据
    mMainId:='';
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select * from fxmaster where cyear=:cyear and cmonth=:cmonth and shortkind=:shortkind');
        Params.ParamByName('cyear').AsInteger:=AR.CYear;
        Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
        Params.ParamByName('shortkind').AsString:=AShortKind;
        Open;
        First;
        if not Eof then
        begin
          mMainId:=FieldByName('mainid').AsString;
        end;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select * from fxmaster where cyear=:cyear and cmonth=:cmonth and shortkind=:shortkind');
        Params.ParamByName('cyear').AsInteger:=AR.CYear;
        Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
        Params.ParamByName('shortkind').AsString:=AShortKind;
        Open;
        First;
        if not Eof then
        begin
          mMainId:=FieldByName('mainid').AsString;
        end;
      end;
    end;
    if mmainid<>'' then
    begin
      //清除主表
      if AWS=False then
      begin
        with InnerQry do
        begin
          Close;
          Sql.Clear;
          Sql.Add('delete from fxmaster where mainid=:mainid');
          Params.ParamByName('mainid').AsString:=mmainid;
          ExecSQL;
        end;
        //清除子表
        with InnerQry do
        begin
          Close;
          Sql.Clear;
          Sql.Add('delete from fxdetail where mainid=:mainid');
          Params.ParamByName('mainid').AsString:=mmainid;
          ExecSQL;
        end;
      end
      else
      begin
        with InnerQryWork do
        begin
          Close;
          Sql.Clear;
          Sql.Add('delete from fxmaster where mainid=:mainid');
          Params.ParamByName('mainid').AsString:=mmainid;
          ExecSQL;
        end;
        //清除子表
        with InnerQryWork do
        begin
          Close;
          Sql.Clear;
          Sql.Add('delete from fxdetail where mainid=:mainid');
          Params.ParamByName('mainid').AsString:=mmainid;
          ExecSQL;
        end;
      end;
    end;
  end;
  //保存主表数据
  mMainID:=GenerateID;
  if AWS=False then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into fxmaster (cyear, cmonth, cwarningcount, cwarning, ctipscount, ctips, cdetail, shortkind, mainid) values (:cyear, :cmonth, :cwarningcount, :cwarning, :ctipscount, :ctips, :cdetail, :shortkind,:mainid)');
      Params.ParamByName('cyear').AsInteger:=AR.CYear;
      Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
      Params.ParamByName('cwarningcount').AsInteger:=AR.WarningCount;
      Params.ParamByName('cwarning').AsString:='';//AR.Warning;
      Params.ParamByName('ctipscount').AsInteger:=AR.TipsCount;
      Params.ParamByName('ctips').AsString:='';//AR.Tips;
      Params.ParamByName('cdetail').AsString:='';//AR.Detail;
      Params.ParamByName('shortkind').AsString:=AShortKind;
      Params.ParamByName('mainid').AsString:=mMainId;
      ExecSQL;
    end;
    //保存子表
    conn.AutoCommit:=False;
    for i:=0 to AR.WarningLength-1 do
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into fxdetail (mainid,warningkey,warningvalue) values (:mainid,:warningkey,:warningvalue)');
        Params.ParamByName('mainid').AsString:=mmainid;
        Params.ParamByName('warningkey').AsString:=AR.WarningKey(i);
        Params.ParamByName('warningvalue').AsString:=AR.WarningValue(i);
        ExecSQL;
      end;
    end;
    {for i:=0 to AR.TipsLength-1 do
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into fxdetail (mainid,tipskey,tipsvalue) values (:mainid,:tipskey,:tipsvalue)');
        Params.ParamByName('mainid').AsString:=mMainid;
        Params.ParamByName('tipskey').AsString:=AR.TipsKey(i);
        Params.ParamByName('tipsvalue').AsString:=AR.TipsValue(i);
        ExecSQL;
      end;
    end;}
    conn.Commit;
    conn.AutoCommit:=True;
  end
  else
  begin
    with InnerQryWork do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into fxmaster (cyear, cmonth, cwarningcount, cwarning, ctipscount, ctips, cdetail, shortkind, mainid) values (:cyear, :cmonth, :cwarningcount, :cwarning, :ctipscount, :ctips, :cdetail, :shortkind,:mainid)');
      Params.ParamByName('cyear').AsInteger:=AR.CYear;
      Params.ParamByName('cmonth').AsInteger:=AR.CMonth;
      Params.ParamByName('cwarningcount').AsInteger:=AR.WarningCount;
      Params.ParamByName('cwarning').AsString:='';//AR.Warning;
      Params.ParamByName('ctipscount').AsInteger:=AR.TipsCount;
      Params.ParamByName('ctips').AsString:='';//AR.Tips;
      Params.ParamByName('cdetail').AsString:='';//AR.Detail;
      Params.ParamByName('shortkind').AsString:=AShortKind;
      Params.ParamByName('mainid').AsString:=mMainId;
      ExecSQL;
    end;
    //保存子表
    connWork.AutoCommit:=False;
    for i:=0 to AR.WarningLength-1 do
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into fxdetail (mainid,warningkey,warningvalue) values (:mainid,:warningkey,:warningvalue)');
        Params.ParamByName('mainid').AsString:=mmainid;
        Params.ParamByName('warningkey').AsString:=AR.WarningKey(i);
        Params.ParamByName('warningvalue').AsString:=AR.WarningValue(i);
        ExecSQL;
      end;
    end;
    {for i:=0 to AR.TipsLength-1 do
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into fxdetail (mainid,tipskey,tipsvalue) values (:mainid,:tipskey,:tipsvalue)');
        Params.ParamByName('mainid').AsString:=mMainid;
        Params.ParamByName('tipskey').AsString:=AR.TipsKey(i);
        Params.ParamByName('tipsvalue').AsString:=AR.TipsValue(i);
        ExecSQL;
      end;
    end;}
    connWork.Commit;
    connWork.AutoCommit:=True;
  end;
end;

procedure Tdm.SaveImportLog(AKind: string; AYear, AMonth: integer;
  ASource, ADispFile: string; ACount: integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into importlog (cyear, cmonth, source, dispfile, reccount, kind) values (:cyear, :cmonth, :source, :dispfile, :reccount, :kind)');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      Params.ParamByName('source').AsString:=ASource;
      Params.ParamByName('dispfile').AsString:=ADispFile;
      Params.ParamByName('reccount').AsInteger:=ACount;
      Params.ParamByName('kind').AsString:=AKind;
      ExecSQL;
    end;
  end
  else
  begin
    with InnerQryWork do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into importlog (cyear, cmonth, source, dispfile, reccount, kind) values (:cyear, :cmonth, :source, :dispfile, :reccount, :kind)');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      Params.ParamByName('source').AsString:=ASource;
      Params.ParamByName('dispfile').AsString:=ADispFile;
      Params.ParamByName('reccount').AsInteger:=ACount;
      Params.ParamByName('kind').AsString:=AKind;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.UpdateRecordCount(AIncCount: integer);
begin
  with InnerQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('update stat set recordcount=recordcount+:AInc where id=1');
    ParamByName('AInc').AsInteger:=AIncCount;
    ExecSQL;
  end;
end;

procedure Tdm.SaveAnalLog(AKind: string; AYear, AMonth, AWarningCount,
  ATipsCount: integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into anallog (kind, cyear, cmonth, warningcount, tipscount) values (:kind, :cyear, :cmonth, :warningcount, :tipscount)');
      Params.ParamByName('kind').AsString:=AKind;
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      Params.ParamByName('warningcount').AsInteger:=AWarningCount;
      Params.ParamByName('tipscount').AsInteger:=ATipsCount;
      ExecSQL;
    end;
  end
  else
  begin
    with InnerQryWork do
    begin
      Close;
      Sql.Clear;
      Sql.Add('insert into anallog (kind, cyear, cmonth, warningcount, tipscount) values (:kind, :cyear, :cmonth, :warningcount, :tipscount)');
      Params.ParamByName('kind').AsString:=AKind;
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      Params.ParamByName('warningcount').AsInteger:=AWarningCount;
      Params.ParamByName('tipscount').AsInteger:=ATipsCount;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.InsertDanwei(cyear, cmonth: integer; c0, c1, c2, c3, c4, c5, c6,
  c7, c8, c9: string; c10, c11: TDate; c12: double; c13, c14, c15, c16,
  c17: integer; c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
  c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41: string; Check:boolean;AWS:boolean=True);
var
  mCount:integer;
begin
  //先检查c0 c1 重复记录，如果存在则更新，否则插入
  mCount:=0;
  if Check = False then
  begin
    if AWS=False then
    begin
      with dm.innerqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from danwei where c0=:c0 and c1=:c1');
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      with dm.innerqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from danwei where c0=:c0 and c1=:c1');
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount = 0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with dm.innerqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into danwei (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33,c34,c35,c36,c37,c38,c39,c40,c41) ');
        Sql.Add('values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27,:c28,:c29,:c30,:c31,:c32,:c33,:c34,:c35,:c36,:c37,:c38,:c39,:c40,:c41)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsInteger:=c13;
        Params.ParamByName('c14').AsInteger:=c14;
        Params.ParamByName('c15').AsInteger:=c15;
        Params.ParamByName('c16').AsInteger:=c16;
        Params.ParamByName('c17').AsInteger:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        Params.ParamByName('c28').AsString:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        Params.ParamByName('c32').AsString:=c32;
        Params.ParamByName('c33').AsString:=c33;
        Params.ParamByName('c34').AsString:=c34;
        Params.ParamByName('c35').AsString:=c35;
        Params.ParamByName('c36').AsString:=c36;
        Params.ParamByName('c37').AsString:=c37;
        Params.ParamByName('c38').AsString:=c38;
        Params.ParamByName('c39').AsString:=c39;
        Params.ParamByName('c40').AsString:=c40;
        Params.ParamByName('c41').AsString:=c41;
        ExecSQL;
      end;
    end
    else
    begin
      with dm.innerqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into danwei (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33,c34,c35,c36,c37,c38,c39,c40,c41) ');
        Sql.Add('values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27,:c28,:c29,:c30,:c31,:c32,:c33,:c34,:c35,:c36,:c37,:c38,:c39,:c40,:c41)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsInteger:=c13;
        Params.ParamByName('c14').AsInteger:=c14;
        Params.ParamByName('c15').AsInteger:=c15;
        Params.ParamByName('c16').AsInteger:=c16;
        Params.ParamByName('c17').AsInteger:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        Params.ParamByName('c28').AsString:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        Params.ParamByName('c32').AsString:=c32;
        Params.ParamByName('c33').AsString:=c33;
        Params.ParamByName('c34').AsString:=c34;
        Params.ParamByName('c35').AsString:=c35;
        Params.ParamByName('c36').AsString:=c36;
        Params.ParamByName('c37').AsString:=c37;
        Params.ParamByName('c38').AsString:=c38;
        Params.ParamByName('c39').AsString:=c39;
        Params.ParamByName('c40').AsString:=c40;
        Params.ParamByName('c41').AsString:=c41;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with dm.innerqry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update danwei set cyear=:cyear, cmonth=:cmonth,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c6=:c6,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,');
        Sql.Add('c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27,c28=:c28,c29=:c29,c30=:c30,c31=:c31,c32=:c32,c33=:c33,c34=:c34,c35=:c35,c36=:c36,c37=:c37,c38=:c38,c39=:c39,c40=:c40,c41=:c41 where c0=:c0 and c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsInteger:=c13;
        Params.ParamByName('c14').AsInteger:=c14;
        Params.ParamByName('c15').AsInteger:=c15;
        Params.ParamByName('c16').AsInteger:=c16;
        Params.ParamByName('c17').AsInteger:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        Params.ParamByName('c28').AsString:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        Params.ParamByName('c32').AsString:=c32;
        Params.ParamByName('c33').AsString:=c33;
        Params.ParamByName('c34').AsString:=c34;
        Params.ParamByName('c35').AsString:=c35;
        Params.ParamByName('c36').AsString:=c36;
        Params.ParamByName('c37').AsString:=c37;
        Params.ParamByName('c38').AsString:=c38;
        Params.ParamByName('c39').AsString:=c39;
        Params.ParamByName('c40').AsString:=c40;
        Params.ParamByName('c41').AsString:=c41;
        ExecSQL;
      end;
    end
    else
    begin
      with dm.innerqryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update danwei set cyear=:cyear, cmonth=:cmonth,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c6=:c6,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,');
        Sql.Add('c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27,c28=:c28,c29=:c29,c30=:c30,c31=:c31,c32=:c32,c33=:c33,c34=:c34,c35=:c35,c36=:c36,c37=:c37,c38=:c38,c39=:c39,c40=:c40,c41=:c41 where c0=:c0 and c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsInteger:=c13;
        Params.ParamByName('c14').AsInteger:=c14;
        Params.ParamByName('c15').AsInteger:=c15;
        Params.ParamByName('c16').AsInteger:=c16;
        Params.ParamByName('c17').AsInteger:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        Params.ParamByName('c28').AsString:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        Params.ParamByName('c32').AsString:=c32;
        Params.ParamByName('c33').AsString:=c33;
        Params.ParamByName('c34').AsString:=c34;
        Params.ParamByName('c35').AsString:=c35;
        Params.ParamByName('c36').AsString:=c36;
        Params.ParamByName('c37').AsString:=c37;
        Params.ParamByName('c38').AsString:=c38;
        Params.ParamByName('c39').AsString:=c39;
        Params.ParamByName('c40').AsString:=c40;
        Params.ParamByName('c41').AsString:=c41;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.DeleteDanwei(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from danwei where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from danwei where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteZhuxiao(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhuxiao where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhuxiao where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.InsertZhuxiao(cyear, cmonth: integer; c0, c1, c2, c3, c4, c5, c6,
  c7: string; c8: TDate; c9, c10: string; c11: TDate; check: boolean;AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对信用号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhuxiao where c6=:c6');
        Params.ParamByName('c6').AsString:=c6;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhuxiao where c6=:c6');
        Params.ParamByName('c6').AsString:=c6;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhuxiao (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhuxiao (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhuxiao set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11 where c6=:c6');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhuxiao set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11 where c6=:c6');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertXuesheng(cyear, cmonth: integer; c0, c1, c2: string;
  c3: TDate; c4, c5, c6, c7, c8: string; c9: TDate; c10, c11:string; c12:integer; c13, c14,
  c15: double; check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from xuesheng where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from xuesheng where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into xuesheng (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into xuesheng (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update xuesheng set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15 where c6=:c6');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update xuesheng set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15 where c6=:c6');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.DeleteXueSheng(AYear,AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from xuesheng where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from xuesheng where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.InsertBujiao(cyear, cmonth: integer; c0, c1, c2, c3, c4, c5, c6,
  c7, c8: string; c9: TDate; c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,
  c20, c21, c22, c23, c24, c25, c26, c27, c28: double; c29, c30, c31: string;
  check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from bujiao where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from bujiao where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into bujiao (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27,:c28,:c29,:c30,:c31)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsFloat:=c10;
        Params.ParamByName('c11').AsFloat:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        Params.ParamByName('c16').AsFloat:=c16;
        Params.ParamByName('c17').AsFloat:=c17;
        Params.ParamByName('c18').AsFloat:=c18;
        Params.ParamByName('c19').AsFloat:=c19;
        Params.ParamByName('c20').AsFloat:=c20;
        Params.ParamByName('c21').AsFloat:=c21;
        Params.ParamByName('c22').AsFloat:=c22;
        Params.ParamByName('c23').AsFloat:=c23;
        Params.ParamByName('c24').AsFloat:=c24;
        Params.ParamByName('c25').AsFloat:=c25;
        Params.ParamByName('c26').AsFloat:=c26;
        Params.ParamByName('c27').AsFloat:=c27;
        Params.ParamByName('c28').AsFloat:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into bujiao (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27,:c28,:c29,:c30,:c31)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsFloat:=c10;
        Params.ParamByName('c11').AsFloat:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        Params.ParamByName('c16').AsFloat:=c16;
        Params.ParamByName('c17').AsFloat:=c17;
        Params.ParamByName('c18').AsFloat:=c18;
        Params.ParamByName('c19').AsFloat:=c19;
        Params.ParamByName('c20').AsFloat:=c20;
        Params.ParamByName('c21').AsFloat:=c21;
        Params.ParamByName('c22').AsFloat:=c22;
        Params.ParamByName('c23').AsFloat:=c23;
        Params.ParamByName('c24').AsFloat:=c24;
        Params.ParamByName('c25').AsFloat:=c25;
        Params.ParamByName('c26').AsFloat:=c26;
        Params.ParamByName('c27').AsFloat:=c27;
        Params.ParamByName('c28').AsFloat:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update bujiao set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27,c28=:c28,c29=:c29,c30=:c30,c31=:c31 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsFloat:=c10;
        Params.ParamByName('c11').AsFloat:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        Params.ParamByName('c16').AsFloat:=c16;
        Params.ParamByName('c17').AsFloat:=c17;
        Params.ParamByName('c18').AsFloat:=c18;
        Params.ParamByName('c19').AsFloat:=c19;
        Params.ParamByName('c20').AsFloat:=c20;
        Params.ParamByName('c21').AsFloat:=c21;
        Params.ParamByName('c22').AsFloat:=c22;
        Params.ParamByName('c23').AsFloat:=c23;
        Params.ParamByName('c24').AsFloat:=c24;
        Params.ParamByName('c25').AsFloat:=c25;
        Params.ParamByName('c26').AsFloat:=c26;
        Params.ParamByName('c27').AsFloat:=c27;
        Params.ParamByName('c28').AsFloat:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update bujiao set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27,c28=:c28,c29=:c29,c30=:c30,c31=:c31 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsFloat:=c10;
        Params.ParamByName('c11').AsFloat:=c11;
        Params.ParamByName('c12').AsFloat:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        Params.ParamByName('c16').AsFloat:=c16;
        Params.ParamByName('c17').AsFloat:=c17;
        Params.ParamByName('c18').AsFloat:=c18;
        Params.ParamByName('c19').AsFloat:=c19;
        Params.ParamByName('c20').AsFloat:=c20;
        Params.ParamByName('c21').AsFloat:=c21;
        Params.ParamByName('c22').AsFloat:=c22;
        Params.ParamByName('c23').AsFloat:=c23;
        Params.ParamByName('c24').AsFloat:=c24;
        Params.ParamByName('c25').AsFloat:=c25;
        Params.ParamByName('c26').AsFloat:=c26;
        Params.ParamByName('c27').AsFloat:=c27;
        Params.ParamByName('c28').AsFloat:=c28;
        Params.ParamByName('c29').AsString:=c29;
        Params.ParamByName('c30').AsString:=c30;
        Params.ParamByName('c31').AsString:=c31;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertZhuanchu(cyear, cmonth: integer; c0, c1, c2, c3, c4, c5, c6,
  c7: string; c8: double; c9, c10, c11, c12: String; c13: TDate; c14, c15, c16,
  c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27: string; check: boolean ; AWS:boolean=True
  );
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from bujiao where c3=:c3');
        Params.ParamByName('c3').AsString:=c3;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from bujiao where c3=:c3');
        Params.ParamByName('c3').AsString:=c3;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    if AWS=False then
    begin
      //插入记录
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhuanchu (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsFloat:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsDate:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        ExecSQL;
      end;
    end
    else
    begin
      //插入记录
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhuanchu (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24,:c25,:c26,:c27)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsFloat:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsDate:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhuanchu set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27 where c3=:c3');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsFloat:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsDate:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhuanchu set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24,c25=:c25,c26=:c26,c27=:c27 where c3=:c3');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsFloat:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsDate:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        Params.ParamByName('c25').AsString:=c25;
        Params.ParamByName('c26').AsString:=c26;
        Params.ParamByName('c27').AsString:=c27;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertJumin(cyear, cMonth: integer; c0, c1, c2: string;
  c3: TDate; c4, c5, c6, c7, c8: string; c9: TDate; c10, c11: string;
  c12: integer; c13, c14, c15: double; check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from jumin where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from jumin where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into jumin (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into jumin (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update jumin set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update jumin set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsDate:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsDate:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsInteger:=c12;
        Params.ParamByName('c13').AsFloat:=c13;
        Params.ParamByName('c14').AsFloat:=c14;
        Params.ParamByName('c15').AsFloat:=c15;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertGaoxueya(cyear, cmonth: integer; c0, c1, c2, c3, c4, c5,
  c6: string; c7, c8: TDate; check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from gaoxueya where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from gaoxueya where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into gaoxueya (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsDate:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into gaoxueya (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsDate:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update gaoxueya set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsDate:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update gaoxueya set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsDate:=c7;
        Params.ParamByName('c8').AsDate:=c8;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertManxingbing(cyear, cmonth: integer; c0, c1, c2, c3,
  c4,c5, c6, c7, c8, c9: string; c10, c11: TDate; c12, c13,
  c14, c15, c16, c17, c18, c19, c20, c21,c22: string; check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对备案号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manxingbing where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manxingbing where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into manxingbing (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into manxingbing (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertZhigongManxingbing(cyear, cmonth: integer; c0, c1, c2, c3,
  c4, c5, c6, c7, c8, c9: string; c10, c11: TDate; c12, c13, c14, c15, c16,
  c17, c18, c19, c20, c21, c22, c23, c24: string; check: boolean; AWS: boolean);
var
  mCount:integer;
begin
  //如果Check=True则比对备案号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigongmanxingbing where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigongmanxingbing where c0=:c0');
        Params.ParamByName('c0').AsString:=c0;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigongmanxingbing (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigongmanxingbing (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17,:c18,:c19,:c20,:c21,:c22,:c23,:c24)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigongmanxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigongmanxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17,c18=:c18,c19=:c19,c20=:c20,c21=:c21,c22=:c22,c23=:c23,c24=:c24 where c0=:c0');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsString:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsDate:=c10;
        Params.ParamByName('c11').AsDate:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        Params.ParamByName('c18').AsString:=c18;
        Params.ParamByName('c19').AsString:=c19;
        Params.ParamByName('c20').AsString:=c20;
        Params.ParamByName('c21').AsString:=c21;
        Params.ParamByName('c22').AsString:=c22;
        Params.ParamByName('c23').AsString:=c23;
        Params.ParamByName('c24').AsString:=c24;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertManbingBianma(cyear, cmonth: integer; c0, c1, c2,c3: string;
  check: boolean; AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对备案号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into manbingbianma (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into manbingbianma (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2, c3=:c3 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2, c3=:c3 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertZhigongManbingBianma(cyear, cmonth: integer; c0, c1,
  c2: string; check: boolean; AWS: boolean);
var
  mCount:integer;
begin
  //如果Check=True则比对备案号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigongmanbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigongmanbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigongmanbingbianma (cyear,cmonth,c0,c1,c2) values (:cyear,:cmonth,:c0,:c1,:c2)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigongmanbingbianma (cyear,cmonth,c0,c1,c2) values (:cyear,:cmonth,:c0,:c1,:c2)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigongmanbingbianma set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigongmanbingbianma set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertYiyuanBianma(cyear, cmonth: integer; c0, c1, c2,
  c3: string; check: boolean;AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对备案号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from manbingbianma where c1=:c1');
        Params.ParamByName('c1').AsString:=c1;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into yiyuanbianma (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into yiyuanbianma (cyear,cmonth,c0,c1,c2,c3) values (:cyear,:cmonth,:c0,:c1,:c2,:c3)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update manxingbing set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3 where c1=:c1');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        ExecSQL;
      end;
    end;
  end;
end;

procedure Tdm.InsertZhigong(cyear, cMonth: integer; c0, c1, c2, c3, c4: string;
  c5: TDate; c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17: string;
  check: boolean;AWS:boolean=True);
var
  mCount:integer;
begin
  //如果Check=True则比对社保号码
  mCount:=0;
  if Check=False then
  begin
    if AWS=False then
    begin
      With InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigong where c4=:c4');
        Params.ParamByName('c4').AsString:=c4;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end
    else
    begin
      With InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('select count(*) as aa from zhigong where c4=:c4');
        Params.ParamByName('c4').AsString:=c4;
        Open;
        First;
        mCount:=FieldByName('aa').AsInteger;
      end;
    end;
  end;
  if mCount=0 then
  begin
    //插入记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigong (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsDate:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('insert into zhigong (cyear,cmonth,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17) values (:cyear,:cmonth,:c0,:c1,:c2,:c3,:c4,:c5,:c6,:c7,:c8,:c9,:c10,:c11,:c12,:c13,:c14,:c15,:c16,:c17)');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsDate:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        ExecSQL;
      end;
    end;
  end
  else
  begin
    //更新记录
    if AWS=False then
    begin
      with InnerQry do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigong set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17 where c4=:c4');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsDate:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        ExecSQL;
      end;
    end
    else
    begin
      with InnerQryWork do
      begin
        Close;
        Sql.Clear;
        Sql.Add('update zhigong set cyear=:cyear,cmonth=:cmonth,c0=:c0,c1=:c1,c2=:c2,c3=:c3,c4=:c4,c5=:c5,c7=:c7,c8=:c8,c9=:c9,c10=:c10,c11=:c11,c12=:c12,c13=:c13,c14=:c14,c15=:c15,c16=:c16,c17=:c17 where c4=:c4');
        Params.ParamByName('cyear').AsInteger:=cyear;
        Params.ParamByName('cmonth').AsInteger:=cmonth;
        Params.ParamByName('c0').AsString:=c0;
        Params.ParamByName('c1').AsString:=c1;
        Params.ParamByName('c2').AsString:=c2;
        Params.ParamByName('c3').AsString:=c3;
        Params.ParamByName('c4').AsString:=c4;
        Params.ParamByName('c5').AsDate:=c5;
        Params.ParamByName('c6').AsString:=c6;
        Params.ParamByName('c7').AsString:=c7;
        Params.ParamByName('c8').AsString:=c8;
        Params.ParamByName('c9').AsString:=c9;
        Params.ParamByName('c10').AsString:=c10;
        Params.ParamByName('c11').AsString:=c11;
        Params.ParamByName('c12').AsString:=c12;
        Params.ParamByName('c13').AsString:=c13;
        Params.ParamByName('c14').AsString:=c14;
        Params.ParamByName('c15').AsString:=c15;
        Params.ParamByName('c16').AsString:=c16;
        Params.ParamByName('c17').AsString:=c17;
        ExecSQL;
      end;
    end;
  end;
end;


procedure Tdm.DeleteZhigong(AYear,AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigong where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigong where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteYiyuanBianma(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from yiyuanbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from yiyuanbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteManbingBianma(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from manbingbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from manbingbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteZhigongManbingBianma(AYear, AMonth:integer;AWS: boolean);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigongmanbingbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigongmanbingbianma where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteBujiao(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from bujiao where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from bujiao where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteZhuanchu(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhuanchu where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhuanchu where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteJumin(AYear,AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from jumin where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from jumin where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteGaoxueya(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from gaoxueya where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from gaoxueya where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteManxingbing(AYear, AMonth:integer;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from manxingbing where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from manxingbing where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.DeleteZhigongManxingbing(AYear, AMonth:integer;AWS: boolean);
begin
  if AWS=False then
  begin
    with pubQry do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigongmanxingbing where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end
  else
  begin
    with pubQryWork do
    begin
      Close;
      SQL.Clear;
      Sql.Add('delete from zhigongmanxingbing where cyear=:cyear and cmonth=:cmonth');
      Params.ParamByName('cyear').AsInteger:=AYear;
      Params.ParamByName('cmonth').AsInteger:=AMonth;
      ExecSQL;
    end;
  end;
end;

procedure Tdm.ResetTable(ATable: string;AWS:boolean=True);
begin
  if AWS=False then
  begin
    with InnerQry do
    begin
      Close;
      Sql.Clear;
      Sql.Add('delete from '+ATable);
      ExecSQL;
    end;
  end
  else
  begin
    with InnerQryWork do
    begin
      Close;
      Sql.Clear;
      Sql.Add('delete from '+ATable);
      ExecSQL;
    end;
  end;
end;

procedure Tdm.ResetBigData;
begin
  with InnerQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('update stat set recordcount=0,analcount=0,viewcount=0,reportcount=0,warningcount=0');
    ExecSQL;
  end;
  ResetTable('stat_detail');
end;

procedure Tdm.UpdateAnalCount;
begin
  with InnerQry do
  begin
    Close;
    Sql.Clear;
    Sql.Add('update stat set analcount=analcount+1 where id=1');
    ExecSQL;
  end;
end;

function Tdm.RemovePercent(AText: string): string;
var
  m:string;
begin
  if Trim(AText)='' then
  begin
    Result:='0';
  end
  else
  begin
    m:=StringReplace(AText,'%','',[rfReplaceAll]);//去百分号
    Result:=StringReplace(m,',','',[rfReplaceAll]);//去千分号
  end;
end;

end.

